<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class Comment extends Model
{
    use SoftDeletes;

    protected $guarded = [];

    public function getList()
    {
        $pageSize = empty($params['page_size']) ? config('sdblog.pageSize') : $params['page_size'];
        $page = empty($params['page']) ? 1 : $params['page'];
        return $this->orderBy('created_at', "desc")
            ->paginate($pageSize, ["*"], 'page', $page);
    }

    public function changeEnable($id, $status)
    {
        return $this->where("id", $id)->update(["is_enable" => $status]);
    }

    public function getMonthCount()
    {
        return $this->where("created_at", ">=", date("Y-m"))
            ->where("created_at", "<", date("Y-m", strtotime("+1 month")))
            ->count();
    }
}
